#pragma once
#include "Mesh.h"

enum ViewDirType
{
	vdX = 0,
	vdY,
	vdZ,
};

class TextureRenderer
{
public:
	TextureRenderer();
	~TextureRenderer();

	HRESULT init(ID3D11Device* pd3dDevice);
	void	release();

	HRESULT render(const WCHAR* meshPath, const WCHAR* texPath, const WCHAR* texNormPath, UINT texHeight);

private:
	HRESULT	createDepthStencil();
	HRESULT	createTexVertexBuffer();

	void renderSubset( UINT iSubset, ID3D11DeviceContext* pContext, ID3DX11EffectTechnique* technique);

	HRESULT renderData(const WCHAR* texPath, UINT texHeight, bool renderNormalsMode);

	HRESULT renderVolumeTexture(ID3D11DeviceContext* pContext, 
		UINT texWidth, UINT texHeight, UINT texDepth, UINT mipLevel, 
		float step, const D3DXMATRIXA16& mView, 
		ViewDirType vdt, bool renderNormalsMode,
		ID3D11Texture3D* tex3d);

	ID3D11Device*	_pd3dDevice;
	Mesh			_mesh;

	ID3D11Texture3D*		_tex3d;

	ID3D11InputLayout*	_pMeshVertexLayout;
	ID3D11InputLayout*	_pTextureVertexLayout;

	ID3D11Buffer*		_pTexVertextBuffer;


	ID3DX11Effect*						_pEffect;
	ID3DX11EffectTechnique*              _pMeshDrawTechnique, *_pTextureDrawTechnique,
										*_pMeshNormDrawTechnique, *_pTextureNormDrawTechnique;
	ID3DX11EffectShaderResourceVariable* _ptxDiffuseVariable;
	ID3DX11EffectShaderResourceVariable* _ptxMSAATexVariable;
	ID3DX11EffectVectorVariable*         _pAmbient;
	ID3DX11EffectScalarVariable*         _pOpacity;
	ID3DX11EffectMatrixVariable*         _pWorldViewProjection;
	ID3DX11EffectScalarVariable*         _pLayer;

};